#include "tcpserver.hpp"
#include "Usermanage.hpp"

using namespace TcpServerModule;

int main(int argc, char* argv[])
{
    if (argc != 2)
    {
        LOG(ERROR) << "wrong option";
        return 1;
    }
    uint16_t port = std::stoi(argv[1]);
    auto um = std::make_unique<UserManagerModule::UserManager>();

    auto tsvr = std::make_unique<TcpServer>(nullptr,port);
    tsvr->RegisterService([&um](int sockfd,const InetAddr &id)
                          { um->AddUser(sockfd,id); }, [&um](const std::string &message)
                          { um->Router(message); }, [&um](const InetAddr &id)
                          { um->DelUser(id); });
    tsvr->InitServer();
    tsvr->Start();
    tsvr->Stop();
    return 0;
}